﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentDemoP18_5 {
    internal class Program {
        static void Main(string[] args) {
           Student outterStu = new Student() { Name = "Tim"};
            Console.WriteLine("HashCode={0},Name={1}", outterStu.GetHashCode(), outterStu.Name);
            Console.WriteLine("======================");
            SomeSideEffect(ref outterStu);
            Console.WriteLine("HashCode={0},Name={1}", outterStu.GetHashCode(), outterStu.Name);
            Console.ReadLine();
            /**
             * 执行结果为：
             * HashCode=46104728,Name=Tim
               ======================
               HashCode=46104728,Name=Tom
               HashCode=46104728,Name=Tom
             * 
             */
        }

        static void SomeSideEffect(ref Student stu) {
            stu.Name= "Tom";
            Console.WriteLine("HashCode={0},Name={1}", stu.GetHashCode(), stu.Name);
        }
    }

    class Student {
        public string Name { get; set; }
    }
}
